{% extends "ejeje/layout.html" %}


{%block title%}Status postjournaler{%if object%}: {{object.id}}{%endif%}{%endblock%}

{%block head%}
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/cupertino/jquery-ui.min.css">
<link rel="stylesheet" type="text/css" href="/media/css/ui.jqgrid.css">
<script type="text/javascript" src="/media/grid.locale-no.js"></script>
<script type="text/javascript">
	jQuery.jgrid.useJSON = true; // true=prefer builtin json parser
  jQuery.jgrid.no_legacy_api = false; // true=only use new api (>3.6) 
</script>
<script type="text/javascript" src="/media/jquery.jqGrid.min.js"></script>
<script type="text/javascript">
/* <![CDATA[ */

jQuery.extend($.fn.fmatter , {
    ejejelink : function(cellvalue, options, rowdata) {
    if(cellvalue.substring(0,7) == 'http://' || cellvalue.substring(0,8) == 'https://') {
        return "<a href='"+cellvalue+"' title='Les dokumentet' rel='facebox'>Åpne</a>";
    } else if(cellvalue.length === 0) {
        return "<a href='/innsyn/"+options.rowId+"' title='Be om innsyn i dette dokumentet' rel='facebox'>Innsyn</a>";
    } else {
        return cellvalue;
    }
}
});
jQuery.extend($.fn.fmatter.ejejelink, {
    unformat : function(cellvalue, options) {
    return jQuery(cellvalue).attr('href');
}
});
var sq;
function do_search() {
  try {
    sq[0].triggerSearch();
  } catch(e) {
    //console.error(e);
  }
}

jQuery(document).ready(function(){
  $("#ejsearch").data("searchstring", "");
  jQuery("#ejlist").jqGrid({
    url:'/katalog.json',
    datatype: 'json',
    mtype: 'GET',
    colNames:['Organisasjon', 'Funker', 'Stanset', 'Sist skannet', 'Nivå'],
    colModel :[ 
      {name:'org', index:'org', sortable:true, width:250},
      {name:'fungerer', index:'fungerer', sortable:true, formatter:'checkbox', width:50}, 
      {name:'stanset', index:'stanset', sortable:true, formatter:'checkbox', width:50}, 
      {name:'dato', index:'dato', sortable:true, classes:'type-date', width:100},
      {name:'orgtype', index:'orgtype', sortable:true }
    ],
    rowNum:70,
    //rowList:[10,20,50],
    sortname: 'org',
    sortorder: 'desc',
    viewrecords: true,
    //footerrow: true,
    loadonce: true, // only load once, never update from server
    gridview: true, // has to be false for 'afterInsertRow' event to fire
    height: 'auto',
    loadError : function(xhr,st,err) {
    	jQuery("#rsperror").html("Type: "+st+"; Response: "+ xhr.status + " "+xhr.statusText);
    }
    
  }); 
  jQuery('#ejlizt td[aria-describedby="ejlist_fungerer"] input[type="checkbox"]:checked ').each(function(i, el) { jQuery(el).parent().css("background", "red"); });
}); 
</script>

{%endblock%}


{%block body%}<div id="rsperror"></div>

<h1 title="">Postjournaler i systemet</h1>
<div id="content">
  <div id="ejsearch"></div>
  <table id="ejlist"></table>
  <div id="ejpager"></div>
</div>
{%endblock%}





